package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.cld.domain.vo.CldTemporaryReplyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldTemporaryReply;
import com.cleaningcloud.cld.service.ICldTemporaryReplyService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 临时工作安排回复Controller
 * 
 * @author cleaningcloud
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/reply")
public class CldTemporaryReplyController extends BaseController
{
    @Autowired
    private ICldTemporaryReplyService cldTemporaryReplyService;

    /**
     * 查询临时工作安排回复列表
     */
    @RequiresPermissions("cld:reply:list")
    @GetMapping("/list")
    public TableDataInfo list(CldTemporaryReplyVo cldTemporaryReplyVo)
    {
        startPage();
        List<CldTemporaryReplyVo> list = cldTemporaryReplyService.selectCldTemporaryReplyList(cldTemporaryReplyVo);
        return getDataTable(list);
    }

    /**
     * 导出临时工作安排回复列表
     */
    @RequiresPermissions("cld:reply:export")
    @Log(title = "临时工作安排回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldTemporaryReplyVo cldTemporaryReplyVo)
    {
        List<CldTemporaryReplyVo> list = cldTemporaryReplyService.selectCldTemporaryReplyList(cldTemporaryReplyVo);
        ExcelUtil<CldTemporaryReplyVo> util = new ExcelUtil<CldTemporaryReplyVo>(CldTemporaryReplyVo.class);
        util.exportExcel(response, list, "临时工作安排回复数据");
    }

    /**
     * 获取临时工作安排回复详细信息
     */
    @RequiresPermissions("cld:reply:query")
    @GetMapping(value = "/{temporaryReplyId}")
    public AjaxResult getInfo(@PathVariable("temporaryReplyId") Long temporaryReplyId)
    {
        return success(cldTemporaryReplyService.selectCldTemporaryReplyByTemporaryReplyId(temporaryReplyId));
    }

    /**
     * 新增临时工作安排回复
     */
    @RequiresPermissions("cld:reply:add")
    @Log(title = "临时工作安排回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldTemporaryReply cldTemporaryReply)
    {
        return toAjax(cldTemporaryReplyService.insertCldTemporaryReply(cldTemporaryReply));
    }

    /**
     * 修改临时工作安排回复
     */
    @RequiresPermissions("cld:reply:edit")
    @Log(title = "临时工作安排回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldTemporaryReply cldTemporaryReply)
    {
        return toAjax(cldTemporaryReplyService.updateCldTemporaryReply(cldTemporaryReply));
    }

    /**
     * 删除临时工作安排回复
     */
    @RequiresPermissions("cld:reply:remove")
    @Log(title = "临时工作安排回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{temporaryReplyIds}")
    public AjaxResult remove(@PathVariable Long[] temporaryReplyIds)
    {
        return toAjax(cldTemporaryReplyService.deleteCldTemporaryReplyByTemporaryReplyIds(temporaryReplyIds));
    }
}
